home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 April / PCWorld_2008-04_cd.bin / komercni software / miton / SystemMechanic7Pro.exe / {app} / smhtml.dll / 1033 / HTML / PROBLEMWIDGET.JS < prev    next >
Text File  |  2008-01-24  |  13KB  |  489 lines

  1.  
  2.  
  3.  
  4. //render custom widgets on page load
  5. function ProblemPageOnLoad()
  6. {  
  7.     var c = new CheckBox();
  8.     c.ID = "chkAll";
  9.     c.OnClickCustomEvent = "_ProblemSelectAll(_IsProblemWidgetCheckBoxChecked('chkAll'));";
  10.     Get('divChkAll').innerHTML  =  c.Render();
  11.     
  12.     var b = new ActionButton()
  13.     b.ID = "btnButtonRepairAll";
  14.     b.Type = ACTION_BUTTON_CUSTOM;
  15.     b.Text = btLOC_RepairAll;
  16.     b.Event = "external.DoOnRepairAllClicked();";
  17.     b.Class = "button_highlighted";
  18.     b.width= btLOC_RepairAll_width;
  19.     b.FloatClass = "floatR";
  20.     Get('divButtonRepairAll').innerHTML  =  b.Render();
  21.     
  22.     var b = new ActionButton()
  23.     b.ID = "btnButtonRepairSelected";
  24.     b.Type = ACTION_BUTTON_CUSTOM;
  25.     b.Text = btLOC_RepairSelected;
  26.     b.Event = "external.DoOnRepairSelectedClicked();";
  27.     b.FloatClass = "floatR";
  28.     b.Width = btLOC_RepairSelected_width;
  29.     Get('divButtonRepairSelected').innerHTML  =  b.Render();
  30.     
  31.      var b = new ActionButton()
  32.      b.ID = "btnAnalyzeNowUnKnownBox";
  33.     b.Type = ACTION_BUTTON_CUSTOM_DROPDOWN; 
  34.     b.Text = btLOC_AnalyzeNow;
  35.     b.Event = "external.DoOnProblemAnalyzeNow()";
  36.     b.Event2 = "_ProblemWidgetAnalyzeNowDrowMenu('"+  b.ID  +"');";
  37.     b.FloatClass = "floatR";
  38.     b.Width = btLOC_AnalyzeNow_width;
  39.     Get('spAnalyzeNowUnKnownBox').innerHTML = b.Render();
  40.     
  41.     var b = new ActionButton()
  42.     b.ID = "btnBackToOverview";
  43.     b.Type = ACTION_BUTTON_CUSTOM; 
  44.     b.Text = btLOC_BackToOverview;
  45.     b.Event = "external.DoOnBackToOverviewClick()";
  46.     b.FloatClass = "floatR";
  47.     b.Width = btLOC_BackToOverview_width;
  48.     Get('spBackToOverview').innerHTML = b.Render();
  49. }
  50.  
  51. // Call it when page load
  52. AddLoadEvent(ProblemPageOnLoad);
  53.  
  54.  
  55. var _ArrayProblemCheckbox = new Array();
  56.  
  57. var _BackUp    = "0";
  58. var _Defrag        = "1";
  59. var _Enable        = "2";
  60. var _Optimize    = "3";
  61. var _Remove    = "4";
  62. var _Repair        = "5";
  63. var _ScanNow    = "6";
  64. var _Schedule    = "7";
  65. var _Start        = "8";
  66. var _MoreInfo        = "9";
  67.  
  68.  
  69.  
  70.  
  71. function _GetProblemWidgetDefaultActionButton(Action, IsDropDown)
  72. {
  73.    var dd = IsDropDown || false;
  74.  
  75.    var b = new ActionButton();
  76.    b.Type = dd ? ACTION_BUTTON_CUSTOM_DROPDOWN  : ACTION_BUTTON_CUSTOM;
  77.    b.Width = 73;
  78.    b.FloatClass = "floatR";
  79.    
  80.    switch ( Action )
  81.     { 
  82.      case _BackUp :
  83.       b.Text = btLOC_BackUP;
  84.       b.Width = btLOC_problem_actions_width;
  85.       return b;
  86.      case _Defrag :
  87.       b.Text = btLOC_Drfrag;
  88.         b.Width = btLOC_problem_actions_width;
  89.       return b;
  90.      case _Enable :
  91.       b.Text = btLOC_Enable;
  92.       b.Width = btLOC_problem_actions_width;
  93.      return b;
  94.      case _Optimize :
  95.       b.Text = btLOC_Optimize;
  96.       b.Width = btLOC_problem_actions_width;
  97.       return b;
  98.      case _Remove : 
  99.       b.Text =btLOC_Remove;
  100.       b.Width =btLOC_problem_actions_width;
  101.       return b;
  102.      case _Repair :
  103.       b.Text = btLOC_Repair;
  104.       b.Width = btLOC_problem_actions_width;
  105.       return b;
  106.      case _ScanNow :
  107.       b.Text = btLOC_ScanNow;
  108.       b.Width = btLOC_problem_actions_width;
  109.       return b;
  110.      case _Schedule :
  111.       b.Text = btLOC_Schedule;
  112.       b.Width = btLOC_problem_actions_width;
  113.       return b;
  114.      case _Start :
  115.       b.Text = btLOC_Start;
  116.       b.Width = btLOC_problem_actions_width;
  117.       return b;
  118.     case _MoreInfo :
  119.       b.Text = btLOC_MoreInfo;
  120.       b.Width = btLOC_problem_actions_width;
  121.       return b;
  122.     }
  123. }
  124.  
  125.  
  126.  
  127. function ProblemWidgetTable(id)
  128. {
  129.   this.tbl = new DataTable();
  130.   this.tbl.ID = id;
  131.    this.tbl.Cellspacing = "0";
  132.   this.tbl.Cellpadding = "0";
  133.   this.tbl.Width = "100%";
  134.   
  135.   
  136.   this.Add = __ProblemWidgetTableAdd;
  137.   this.Check = __ProblemWidgetTableCheck;
  138.   
  139.     // obj : problemwidget object
  140.     function __ProblemWidgetTableAdd( obj)
  141.     {
  142.       if(( obj.IsCritical) && (this.tbl.Count()>0))
  143.         this.tbl.AddWithKeyByIndex(obj.ID,0, obj.Render() );
  144.       else
  145.         this.tbl.AddWithKey(obj.ID,obj.Render() );  
  146.     }
  147.  
  148.     //value :bool
  149.     function __ProblemWidgetTableCheck(value)
  150.     {
  151.       _SetProblemWidgetCheckBoxesState( value );
  152.     }
  153.  
  154. }
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161. function ProblemWidget( id )
  162. {
  163.   this.ID = id;
  164.   this.Class = "module_items list";
  165.   
  166.   this.IsChecked = false;
  167.   this.IsCritical = false;
  168.   this.IsCriticalSection = false;
  169.   
  170.   this.DefaultAction = _Enable;
  171.   
  172.   
  173.   this.lblHeader = new Label();
  174.   this.lblHeader.ID = "header_" + id;
  175.   this.lblHeader.Text = "Header";
  176.   this.lblHeader.Class = "module_item_heading";
  177.   
  178.   this.lblDetails = new Label();
  179.   this.lblDetails.ID = "details_" + id;
  180.   this.lblDetails.Text = "Details";
  181.   this.lblDetails.Class = "description";
  182.   
  183.   this.chk = new CheckBox();
  184.   this.chk.ID = "chk_" + id; 
  185.   
  186.  
  187.  this.Render = __ProblemWidgetRender;
  188.  this.IsRendered = __ProblemWidgetIsRendered;
  189.  this.Select = __ProblemWidgetSelect;
  190.  
  191.  
  192.  function __ProblemWidgetIsRendered()
  193. {
  194.   return  Get( this.ID ) == null ? false : true;
  195. }
  196.  
  197.  function __ProblemWidgetRender()
  198.   {
  199.     var content = "";
  200.     var checkvalue ="";
  201.     var tdCheckboxClass = "selection_box";
  202.     var tdDetailsClass = "selection_box_text";
  203.     
  204.     if(this.IsChecked)
  205.     {
  206.       tdCheckboxClass = "selection_box_darkblue";
  207.       tdDetailsClass = "bg_selected_lightblue";
  208.       checkvalue = "checked";
  209.       this.chk.State = _CHECKBOX_CHECKED;
  210.     }
  211.    
  212.    content += "<table id=\"" + this.ID + "\" cellspacing=0 cellpadding=0 border=0 width=100% class=\""+ this.Class +"\">";
  213.    content +=                    "<tr id=\"td_chk_" + this.ID + "\"     class=\"" + tdDetailsClass + "\" >";
  214.    content +=                    "<td width=\"20px\"  class=\"checkbox_col\"  valign=\"middle\" >";
  215.    if(!this.IsCriticalSection)
  216.    {
  217.       this.chk.OnClickCustomEvent = "_ProblemWidgetCheckBoxOnclick('" + this.ID +"', _IsProblemWidgetCheckBoxChecked('chk_" + this.ID + "'));";
  218.       content += this.chk.Render();
  219.     }
  220.     else
  221.       content += "  ";
  222.    content +=                    "</td>";
  223.    
  224.    content +="<td  id=\"td_text_" + this.ID + "\"    class=\"" + tdDetailsClass + "\" >";
  225.    
  226.    if(this.IsCritical)
  227.      this.lblHeader.Class =  this.lblHeader.Class + " red";
  228.    content += this.lblHeader.Render(); 
  229.    content += this.lblDetails.Render();
  230.    
  231.    content +="</td>\n\n";
  232.    
  233.    //var button = _GetProblemWidgetDefaultActionButton(this.DefaultAction, !this.IsCriticalSection);
  234.    var button = _GetProblemWidgetDefaultActionButton(this.DefaultAction, true);
  235.    
  236.    button.ID = "btn_" + this.ID ;
  237.    
  238.    if(!this.IsCriticalSection)
  239.    {
  240.      content +="\n\t<td width=\"100x\"   id=\"td_button_" + this.ID + "\"  valign=top  class=\"" + tdDetailsClass + "\">\n";
  241.      
  242.      button.Event = "external.DoOnProblemButtonClicked('"+ this.ID +"');";
  243.      button.Event2 = "_ProblemWidgetDrowMenu('"+ this.ID+"','btn_"+ this.ID +"');";
  244.      content += button.Render();
  245.     _ArrayProblemCheckbox[_ArrayProblemCheckbox.length] =  this.ID;
  246.  
  247.    }
  248.    else
  249.    {
  250.      content +="\n\t<td   width=\"100x\"  id=\"td_button_" + this.ID + "\"  valign=top   class=\"selection_box_text\">\n";
  251.      
  252.      button.Event = "external.DoOnProblemButtonClicked('"+ this.ID +"');";
  253.      button.Event2 = "_ProblemWidgetDrowMenu('"+ this.ID+"','btn_"+ this.ID +"');";
  254.      
  255.      //button.Event = "external.DoOnProblemButtonClicked('" + this.ID + "');";
  256.      content += button.Render();
  257.    }
  258.    content +="\n\t</td>\n\n";
  259.  content +=                "</tr>";
  260.  content +=            "</table>";
  261.  
  262.   
  263.  return content;
  264.    
  265.    }
  266.    
  267.  //value : bool
  268.  function __ProblemWidgetSelect(value)
  269.  {
  270.    if(this.IsRendered())
  271.    {
  272.     var tdCheckboxClass = "selection_box";
  273.     var tdDetailsClass = "";
  274.     
  275.     if(value)
  276.     {
  277.       tdCheckboxClass = "bg_selected_lightblue";
  278.       tdDetailsClass = "bg_selected_lightblue";
  279.     }
  280.     
  281.     var td1 =  Get("td_chk_" + this.ID) ;
  282.     var td2 =  Get("td_text_" + this.ID) ;
  283.     var td3 =  Get("td_button_" + this.ID) ;
  284.     
  285.     if( td1!=null)
  286.        td1.className = tdCheckboxClass;
  287.     
  288.     if( td2!=null)
  289.        td2.className = tdDetailsClass;
  290.     
  291.     if( td3!=null)
  292.        td3.className = tdDetailsClass;
  293.    
  294.    }
  295.  }
  296.  
  297.  
  298.  
  299.    
  300. }
  301.  
  302.  
  303.  
  304. //*************************  Problem Internal functions ****************************************************
  305.  
  306.  
  307. function _AddProblemToList(ID, IsCritical, IsChecked, HeaderText, DetailText, DefaultAction, IsCriticalSection)
  308. {
  309.   var p = new ProblemWidget(ID);
  310.   p.IsCritical = IsCritical;
  311.   p.IsChecked = IsChecked;
  312.   p.lblHeader.Text = URLDecode(HeaderText);
  313.   p.lblDetails.Text = URLDecode(DetailText);
  314.   p.DefaultAction = DefaultAction;
  315.   p.IsCriticalSection = IsCriticalSection;
  316.   
  317.   if(!IsCriticalSection)
  318.   {
  319.     var t = new ProblemWidgetTable('proTable');
  320.     t.Add( p );
  321.     if( Get( t.tbl._ClientID() ) == null )
  322.       Get("divProblems").innerHTML += t.tbl.Render();
  323.   }else
  324.   {
  325.     var t = new ProblemWidgetTable('warTable');
  326.     t.Add( p );
  327.     if( Get( t.tbl._ClientID() ) == null )
  328.       Get("divWarnings").innerHTML += t.tbl.Render();
  329.   }
  330.   _SetProblemCount();
  331.   _GetAndSetCheckBoxState();
  332. }
  333.  
  334. function _SetProblemCount()
  335. {
  336.   var t1 = new ProblemWidgetTable('proTable');
  337.   var t2 = new ProblemWidgetTable('warTable');
  338.   var problemcout = t1.tbl.Count();
  339.   var warningcout = t2.tbl.Count();
  340.    
  341.   SetDisplayWidget('tblWarningsHeader', (warningcout>0));
  342.   SetDisplayWidget('tblProblemsHeader', (problemcout>0));
  343.   SetDisplayWidget('divProblemBallon',  (problemcout>0), true);
  344. }
  345.  
  346. function _ProblemSelectAll(Value)
  347. {
  348.    var t1 = new ProblemWidgetTable('proTable');
  349.    t1.Check( Value );
  350. //   var t2 = new ProblemWidgetTable('warTable');
  351. //   t2.Check( Value );
  352. }
  353.  
  354.  
  355. function _ProblemWidgetCheckBoxOnclick( id, value)
  356. {
  357.   var p = new ProblemWidget(id);
  358.   p.Select(value);
  359.   
  360.   try
  361.   {
  362.    external.DoOnProblemCheckboxClicked( id, value ); 
  363.    }catch(e)
  364.    {
  365.     //alert(id + " - " + value);
  366.    }
  367.    
  368.    _GetAndSetCheckBoxState();
  369.    
  370. }
  371.  
  372. function _GetAndSetCheckBoxState()
  373. {
  374.   var x = 0;
  375.   var checked = false;
  376.   var unchecked = false;
  377.   //var chk = null;
  378.   var passingvalue = 1;
  379.   
  380.    for (var x = 0; x < _ArrayProblemCheckbox.length; x++)
  381.    {
  382.     var c = new CheckBox();
  383.     c.ID = "chk_" + _ArrayProblemCheckbox[x];
  384.    if( c.IsRendered())
  385.    {
  386.     if(c.IsChecked())
  387.        checked = true;
  388.     else
  389.        unchecked = true; 
  390.        }
  391.    }
  392.   
  393.   if((!checked) && (unchecked)) passingvalue = 1;
  394.   if((checked) && (!unchecked)) passingvalue = 2;
  395.   if((checked) && (unchecked)) passingvalue = 3;
  396.         
  397.   _SetCheckBoxState(passingvalue);
  398.   //alert(passingvalue);
  399. }
  400.  
  401.  
  402.  
  403. function _SetCheckBoxState(state)
  404. {
  405.    var c = new CheckBox();
  406.    c.ID = "chkAll";
  407.     
  408.   switch(state)
  409.   { 
  410.     case 1:
  411.      c.SetState(_CHECKBOX_UNCHECKED);
  412.      break;
  413.     case 2:
  414.      c.SetState(_CHECKBOX_CHECKED);
  415.      break;
  416.     case 3:
  417.      c.SetState(_CHECKBOX_MIX);
  418.      break;
  419.   }
  420. }
  421.  
  422.  
  423. function _SetProblemWidgetCheckBoxesState(  state )
  424. {
  425.    for (var x = 0; x < _ArrayProblemCheckbox.length; x++)
  426.    {
  427.     var c = new CheckBox();
  428.     c.ID = "chk_" + _ArrayProblemCheckbox[x];
  429.     if( c.IsRendered())
  430.     {
  431.     c.Check(state);
  432.     _ProblemWidgetCheckBoxOnclick( _ArrayProblemCheckbox[x], state);
  433.     }
  434.    }
  435. }
  436.  
  437.  
  438. function _ProblemWidgetDrowMenu( objID, imgID )
  439. {
  440.    var x = findPosX( imgID );
  441.    var y = findPosY( imgID )  + 22 - GetScrollTop();
  442.    try
  443.    {
  444.     external.DoOnProblemDropDownClicked( objID, x, y ); 
  445.    }catch(e)
  446.    {    
  447.       moveDiv("move", x, y);
  448.    }
  449. }
  450.  
  451.  
  452.  
  453. function _ProblemWidgetAnalyzeNowDrowMenu(  imgID )
  454. {
  455.    var x = findPosX( imgID );
  456.    var y = findPosY( imgID )  + 22 - GetScrollTop();
  457.    try
  458.    {
  459.     external.DoOnProblemAnalyzeNowDropDownClicked(x, y ); 
  460.    }catch(e)
  461.    {    
  462.       moveDiv("move", x, y);
  463.    }
  464. }
  465.  
  466.  
  467. function _IsProblemWidgetCheckBoxChecked(id)
  468. {
  469.   var c = new CheckBox();
  470.   c.ID = id;
  471.   
  472.   var  s = c.GetState();
  473.   if(( s == 0) || ( s == 4) )
  474.     return true;
  475.   else
  476.    return false;  
  477.   
  478.   //return c.IsChecked();
  479. }
  480.  
  481. function SetLanguage (language){
  482.     Get("aLOC_Configure1").innerHTML= aLOC_Configure1;
  483.     Get("aLOC_Configure2").innerHTML= aLOC_Configure2;
  484.     Get("aLOC_Configure3").innerHTML= aLOC_Configure3;
  485.     Get("pLOC_AnalyzeRequired").innerHTML= pLOC_AnalyzeRequired;
  486.     Get("pLOC_AnalyzeRequiredDescription").innerHTML= pLOC_AnalyzeRequiredDescription;
  487.     Get("pLOC_NoProblemsFound").innerHTML= pLOC_NoProblemsFound;
  488.     Get("pLOC_NoProblemsFoundDescription").innerHTML= pLOC_NoProblemsFoundDescription;
  489. }